var HtmlUtil = Java.type("com.gitee.fantaros.util.HtmlUtil"), jstr = Java.type("java.lang.String"),
    JsonWriter = Java.type("com.gitee.fantaros.util.JsonWriter"),
    Engine = Java.type("com.gitee.fantaros.engine.FanJsEngine"), engine = Engine.getInstance();

engine.loadJs("scripts/json2.js");

var datas = [], readjson = function (res, doc) {
   //    var body = doc.body(), uls = body.select("div.block_content div.container div.main_content div.wrapper div.main-cmps div.chart div.chart_body ul.chartlist");
       var ul = doc.body().select("ul.chartlist").get(0);
       ul.children().forEach(function (li) {
           engine.info(li.text());
           var data = {}, prdname = li.select("span.prdname").getFirst().text(),
           count = li.select("span.count").getFirst().text();
           engine.info("result: " + prdname + " : " + count);
           data["cpu"] = prdname;
           data["score"] = count.replaceAll(',', '');
           datas.push(data);
       });
   };
   HtmlUtil.analyzeUrl("https://www.cpubenchmark.net/multithread/", readjson);
   HtmlUtil.analyzeUrl("https://www.cpubenchmark.net/multithread/page2", readjson);
   HtmlUtil.analyzeUrl("https://www.cpubenchmark.net/multithread/page3", readjson);
   HtmlUtil.analyzeUrl("https://www.cpubenchmark.net/multithread/page4", readjson);
   HtmlUtil.analyzeUrl("https://www.cpubenchmark.net/multithread/page5", readjson);
   HtmlUtil.analyzeUrl("https://www.cpubenchmark.net/multithread/page6", readjson);
   HtmlUtil.analyzeUrl("https://www.cpubenchmark.net/multithread/page7", readjson);
   JsonWriter.writeToJson("output/cpu.json", JSON.stringify(datas));